<?php
session_start();
require_once("./config/include.inc.php");
$sql = "";
$currentType = $_POST["currentType"];	
$doFlag = $_POST["doFlag"];
$transID = $_POST["transID"];


if($doFlag == "doDelete"){
	$sqlDel = "delete from translate where id= $transID";
	$db->Execute($sqlDel);
}else if($doFlag == "toList"){
	//return list
}


if ($currentType == ""){
	$currentType = 1; //默认显示邮件内容的翻译列表
}
$sql = "select * from translate where type = $currentType order by order_id asc";
$result = $db->Execute($sql);
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!--Begin:head-->
<head>

<link rel="shortcut icon" href="/vincent/images/favicon.ico" type="image/x-icon" />
<link href="/vincent/common/main.css" media="all" rel="stylesheet" type="text/css" />

<script src="/vincent/common/jquery-1.6.4.min.js" type="text/javascript"></script>



<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<meta name="keywords" content="" />
<meta name="description" content="" />

<title>Translate</title>

</head> 
<!--End:head-->




<body>
<form name="listTransForm" action="trans-list.php" method="post">


<div id="container" >	
<div class="grayTable">
<caption>翻译列表:
<a href="javascript:toList(1)">邮件内容</a>
<a href="javascript:toList(2)">短文内容</a>
<a href="javascript:toList(3)">长段内容</a>
&nbsp; <input type="button" value="新增翻译" onclick="addTrans()">
</caption><br>
<table width="100%" >
<thead>
	<tr>
		<th scope="col" width=70>OrderID</th>
	    <th scope="col" >中文内容</th>
		<th scope="col" >英文内容</th>
		<th scope="col" >日文内容</th>
		<th scope="col" width=95>操作</th>
	</tr>
</thead>

<tbody>
<?php
	while (!$result->EOF) {
		$tempId = $result->fields['id'];
		$strTR = "<tr >";
		$strTR = $strTR."<td>".$result->fields['order_id']."</td>";
		$strTR = $strTR."<td ><textarea cols='30'  rows='4'>".$result->fields['chinese_content']."</textarea> </td>";		
		$strTR = $strTR."<td ><textarea cols='30' rows='4'>".$result->fields['english_content']."</textarea> </td>";
		$strTR = $strTR."<td ><textarea cols='30' rows='4'>".$result->fields['japanese_content']."</textarea> </td>";
		$strTR = $strTR."<td><input type='button' value='编辑' onclick='doEdit(".$result->fields['id'].")'><input type='button' value='删除' onclick='doDelete(".$result->fields['id'].")'></td>";
		$strTR = $strTR."</tr>";
		echo $strTR;
		echo "<input type='hidden' id='$tempId"."_chinese' value='".$result->fields['chinese_content']."' >";
		echo "<input type='hidden' id='$tempId"."_english' value='".$result->fields['english_content']."' >";
		echo "<input type='hidden' id='$tempId"."_japanese' value='".$result->fields['english_content']."' >";
		$result->MoveNext();	
	}
?>
</tbody>

</table>



</div>
</div><!--end:container -->
<input type="hidden" name="doFlag" id="doFlag" >
<input type="hidden" name="transID" id="transID" >
<input type="hidden" name="currentType" id="currentType" >
</form>
	
	
<form name="inputTransForm" action="trans-input.php" method="post">
<input type="hidden" name="id" id="id" >
<input type="hidden" name="action" id="action" >
</form>
			
<br><br><br><br>
</body>




</html>

<script>


function toList(currentType){
	document.getElementById('doFlag').value = "toList";
	document.getElementById('currentType').value = currentType;
	document.listTransForm.submit();
}

function  addTrans(){
	document.getElementById('action').value = "add";
	document.inputTransForm.submit();
}	


function doDelete(id){
	if(confirm("是否删除这条翻译记录,删除后不可恢复,是否继续?")){ 
		document.getElementById('doFlag').value = "doDelete";
		document.getElementById('transID').value = id;
		document.listTransForm.submit();
	}else{
		return;
	}
}


function doEdit(id){
	document.getElementById('action').value = "edit";
	document.getElementById('id').value = id;
	document.inputTransForm.submit();
}


function doCopyChinese(id){
	var str = document.getElementById(id+"_chinese").value;
	copy(str);
}

function doCopyEnglish(id){
	var str = document.getElementById(id+"_english").value;
	alert(str);
}

function doCopyJapanese(id){
	var str = document.getElementById(id+"_japanese").value;
	alert(str);
}



</script>

